﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EtcpSharp
{
    /// <summary>
    /// ETCP服务
    /// </summary>
    public interface IETCPSocketService : IDisposable
    {
        /// <summary>
        /// 地址
        /// </summary>
        string Host { get; set; }

        /// <summary>
        /// 端口
        /// </summary>
        ushort Port { get; set; }

        /// <summary>
        /// 日志输出
        /// </summary>
        Action<string> Log { get; set; }

        /// <summary>
        /// 初始化
        /// </summary>
        string Initialize();

        /// <summary>
        /// 启动服务
        /// </summary>
        void Start();

        /// <summary>
        /// 关闭服务器
        /// </summary>
        void Colse();

        /// <summary>
        /// 获取客户端
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        IClientSocketSessionServer GetClient(string id);

        /// <summary>
        /// 发送数据
        /// </summary>
        /// <param name="clientid"></param>
        /// <param name="sb"></param>
        void Send(string clientid, StringBuilder sb);

        /// <summary>
        /// 发送数据
        /// </summary>
        /// <param name="client"></param>
        /// <param name="sb"></param>
        void Send(IClientSocketSessionServer client, StringBuilder sb);

        /// <summary>
        /// 关闭客户端
        /// </summary>
        /// <param name="id"></param>
        void ColseClient(string id);

        /// <summary>
        /// 收到客户端传到的数据
        /// </summary>
        event EventHandler<ETCPClientDataReceivedEventArgs> Received;

        /// <summary>
        /// 收到客户端连接
        /// </summary>
        event EventHandler<ETCPClientConnectedEventArgs> Connected;

        /// <summary>
        /// 断开连接
        /// </summary>
        event EventHandler<ETCPClientDisconnectedEventArgs> Disconnected;
    }
}